<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>管理后台</title>
    <link rel="stylesheet/less" href="../../../static/css/index.less"/>
    <link rel="stylesheet" href="../../../static/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../../static/css/jquery.pagination.css"/>
    <script src="../../../static/js/jquery-1.12.3.js"></script>
    <script src="../../../static/js/less.min.js"></script>
    <script src="../../../static/layui/layui.js"></script>
    <script src="../../../static/js/ajaxfileupload.js"></script>
    <script src="../../../static/layer/layer.js"></script>
    <SCRIPT language=javascript src="../../static/layer/layer.js"></SCRIPT>
</head>
<style>
    #test1{
        display: inline-block;
        width:15%;
    }
</style>
<body class="layui-layout-body">

{% include "/admin/top.html" %}
{% include "/admin/left.html" %}

<div id="box" class="fl">
    <div class="content" style="height: 100%">
        <h3 style="color:  #3D89CB">商家套餐列表</h3>
        <div class="search">
            <label>选择商家：</label>
            <select id="uid">
                <option value="">选择商家</option>
                {% if business %}
                {% for d in business %}
                <option value="{{ d.bid }}">{{ d.username }}</option>
                {% endfor %}
                {% endif %}
            </select>
            <label>开始日期：</label><input type="text" class="layui-input" id="test1" value=""  placeholder="请输入相应的日期" style="width: 150px">
            <label>结束日期：</label><input type="text" class="layui-input" id="test2" value=""  placeholder="请输入相应的日期" style="width: 150px; display: inline-block;">
            <button onclick="get_data(1)" class="s_button" style="background-color:  #3D89CB">搜索</button>
        </div>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <thead>
            <tr>
                <th width="8%">ID</th>
                <th>用户名</th>
                <th>昵称</th>
                <th>套餐名称</th>
                <th>购买数量</th>
                <th>使用数量</th>
                <th>有效次数</th>
                <th>有效时间(天)</th>
                <th>单价</th>
                <th>订单金额</th>
                <th>订单时间</th>
            </tr>
            </thead>
            <tbody id="content">
            </tbody>
        </table>
        <div id="page" class="ui-pagination-container">
        </div>
    </div>
</div>
</div>
<input type="hidden" value="1" id="p" >
</body>
</html>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#test1', //指定元素
        });
        laydate.render({
            elem: '#test2', //指定元素
        });
    });
    get_data(1);
    function get_data(p){
        var stime = $('#test1').val();
        var etime = $('#test2').val();
        var uid = $('#uid').val();
        $.ajax({
            url:"/admin/business_order_data_post",
            type:"post",
            data:{
                'stime':stime,
                'etime':etime,
                'uid':uid,
                'p':p
            },
            dataType:"json",
            success:function(msg){
                var q = '';
                if (msg.status == 1){
                    for (var i = 0; i < msg.res.length; i++){
                        q += '<tr>';
                        q += '<td>' + msg.res[i].bid + '</td>';
                        q += '<td>' + msg.res[i].username + '</td>';
                        q += '<td>' + msg.res[i].nickname + '</td>';
                        q += '<td>' + msg.res[i].recharge_name + '</td>';
                        q += '<td>' + msg.res[i].num + '</td>';
                        q += '<td>' + msg.res[i].use_num + '</td>';
                        q += '<td>' + msg.res[i].recharge_num + '</td>';
                        q += '<td>' + msg.res[i].useful_time + '</td>';
                        q += '<td>' + msg.res[i].recharge_price + '</td>';
                        q += '<td>' + msg.res[i].pay_money + '</td>';
                        q += '<td>' + msg.res[i].add_time + '</td>';
                        q += '</tr>';
                    }
                }else {
                    q  += '<tr><td colspan=9 align="center">无数据</td></tr>';
                }
                $('#content').html(q);
                $('#page').html(msg.page);
                $('#p').val(msg.p);
            }
        })
    }

</script>
